﻿// ===============================================================================
// DotNet.Platform 开发框架 2016 版权所有
// ===============================================================================

using System;
using System.Web.Mvc;
using DotNet.Extensions;
using DotNet.Web.Controllers;
using DotNet.JCore.Entity;
using DotNet.Auth.Utility;

namespace Zeniths.Hr.Controllers
{
    public class TimePeriodSumController : BaseController
    {
        private TimePeriodSumService Service = new TimePeriodSumService();
        public ActionResult Index()
        {
            var currentUser = AuthHelper.GetSessionUser();
            if (!currentUser.IsAdmin)
            {
                ViewBag.pointId = CurrentEmployee.PointId;
            }
            return View();
        }
        public ActionResult Grid(string startDate, string endDate, string PointID, string StationId)
        {
            //先统计一下当日数据，将当日数据插入表中，再执行查询
            Service.Proc_InspectorRegistrationSum("Proc_TimePeriodSum");
            var list = Service.GetPageList(PageInfo(), startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull(), PointID,StationId);
            return View(list);
        }
        public ActionResult Export(string startDate, string endDate, string PointID, string StationId)
        {
            return Export(Service.GetList(startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull(), PointID,StationId));
        }
        private ActionResult NotFound(string id)
        {
            return NotFound("获取 信息 错误", $"无法找到 主键 = {id} 的信息");
        }
    }
}
